package com.qianli.cashmama.product.server.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.qianli.cashmama.product.server.dao.AppDao;
import com.qianli.cashmama.product.server.entity.AppEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: Karl
 * Date: 2019-09-25
 * Time: 11:17:08.720
 */

@Repository
public class AppDaoImpl extends AbstractBaseMapper<AppEntity> implements AppDao {

    @Override
    public List<AppEntity> selectAppListByParams(Map<String, Object> params) {
        if (!params.containsKey("deleted")) {
            params.put("deleted", 0);
        }
        return getSqlSession().selectList(this.getStatement("selectByParams"), params);
    }

    @Override
    public AppEntity selectAppByAppCode(String appCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("appCode", appCode);
        List<AppEntity> list = this.selectAppListByParams(params);
        if (list == null || list.size() == 0) {
            return null;
        }
        return list.get(0);
    }

    @Override
    public List<AppEntity> getAllApps() {
        return getSqlSession().selectList(this.getStatement("getAllApps"));
    }
}